package com.example.springbootelasticjob.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.example.autoconfig.ElasticSimpleJob;
import com.example.springbootelasticjob.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @ClassName SimpleJob
 * @Description TODO
 * @Author wyp
 * @Date 2023/8/15 15:44
 * @Version 1.0
 */
@Slf4j
//@ElasticSimpleJob(
//        jobName = "mySimpleJob",
//        cron = "0/10 * * * * ?",
//        shardingTotalCount = 1,
//        overwrite = true)
public class MySimpleJob implements SimpleJob {

    @Autowired
    private OrderService orderService;
    @Override
    public void execute(ShardingContext shardingContext) {
        for (int i = 0; i < 10; i++) {
            orderService.insertOrder();
        }
    }
}
